/**
 * Created by LeungZ on 2016/8/8.
 */
import temp from './deployment.html';
import ctrl from './deployment.ctrl.js';

import tempDtl from './detail/detail.html';
import ctrlDtl from './detail/detail.ctrl.js';

export default angular.module('ctg-k8sconsole').config(['$stateProvider', $stateProvider=> {
    $stateProvider.state('k8s-dp', {
        url: '/k8s/dp?kDbCode',
        templateUrl: temp,
        controller: ctrl,
        controllerAs: 'list',
        resolve: {
            list: ['serviceSrv', 'ctgNotification', '$stateParams', function (serviceSrv, ctgNotification, $stateParams) {
                return serviceSrv.getDPList({page: 1, code: $stateParams.kDbCode}).catch(function (data) {
                    ctgNotification.error('获取服务列表数据有误.');
                });
            }]
        }
    }).state('k8s-dp-detail', {
        url: '/k8s/dp/:name?namesp&kDbCode&appId',
        templateUrl: tempDtl,
        controller: ctrlDtl,
        controllerAs: 'ser',
        resolve: {
            detail: ['serviceSrv', 'ctgNotification', '$stateParams', function (serviceSrv, ctgNotification, $stateParams) {
                return serviceSrv.getDPDetail({
                    namesp: $stateParams.namesp,
                    name: $stateParams.name,
                    code: $stateParams.kDbCode
                }).catch(function (data) {
                    ctgNotification.error('获取服务详情数据有误.');
                });
            }]
        }
    })
}]);